﻿using System;
using System.Text;

namespace dotHTML.HTML {
    /// <summary>
    /// Represents a stylesheet.
    /// </summary>
    [Serializable]
    public class Style : Element {
        private string _type;
        private string _media;
        private bool _disabled;

        /// <summary>
        /// Constructs a new Style element of the given type.
        /// </summary>
        /// <param name="type">The MIME type of this stylesheet.</param>
        public Style(string type) {
            _type = type;
        }

        /// <summary>
        /// Determines the MIME type of this stylesheet.
        /// </summary>
        public string Type {
            get { return _type; }
            set { _type = value; }
        }

        /// <summary>
        /// Determines the media query for this stylesheet.
        /// </summary>
        public string Media {
            get { return _media; }
            set { _media = value; }
        }

        /// <summary>
        /// Determines whether or not this stylesheet is to be applied to the
        /// document.
        /// </summary>
        public bool Disabled {
            get { return _disabled; }
            set { _disabled = value; }
        }

        /// <summary>
        /// Gets a formatted string of all local attributes of this element
        /// (not including the base attributes).
        /// </summary>
        /// <param name="sb">The StringBuilder to write this element's
        /// attribute data to.</param>
        protected override void WriteLocalAttributes(StringBuilder sb) {
            AttributeWriter.Write(sb, _disabled, "disabled");
            AttributeWriter.Write(sb, _media, "media");
            AttributeWriter.Write(sb, _type, "type");
        }
    }
}
